'''
Created on 27/apr/09

@author: Riccardo Cagnasso
'''
from Controller.AuthHandler import AuthHandler
from Datastore.Ticket.Ticket import Ticket
from Datastore.Ticket.Entry import Entry
from google.appengine.api import users

import cgi

class AddEntry(AuthHandler):
    '''
    This is the class that add a new entry to the ticket.
    '''
    def post(self):
        tid=self.request.get('id')
        ticket=Ticket.get(tid)
        user = users.get_current_user()
        
        content = cgi.escape(self.request.get('content'))
        Entry(
              ticket=ticket,
              content=content,
              author=user
              ).put()
              
        self.redirect("viewTicket?id="+tid)
        